CC := gcc
INCLUDE := -I ./cgi/include -I ./cgi/sqlite
SRC := ./cgi/src
CGI_SRC := ./cgi
CGI_BIN := ./cgi-bin
LDFLAGS := -L ./cgi/sqlite -lsqlite3 -lpthread -ldl
OBJS := util.o kmp.o form.o parcel.o

all: storage.cgi index.cgi init.cgi boa

boa:
	cd ./boa-src && make && cp boa ..
init.cgi: $(CGI_SRC)/init.c
	$(CC) $(INCLUDE) $(CGI_SRC)/init.c -o $(CGI_BIN)/init.cgi $(LDFLAGS)
index.cgi: $(CGI_SRC)/index.c $(OBJS)
	$(CC) $(INCLUDE) $(OBJS) $(CGI_SRC)/index.c -o $(CGI_BIN)/index.cgi $(LDFLAGS)
storage.cgi: $(CGI_SRC)/storage.c $(OBJS)
	$(CC) $(INCLUDE) $(OBJS) $(CGI_SRC)/storage.c -o $(CGI_BIN)/storage.cgi $(LDFLAGS)
util.o: $(SRC)/util.c
	$(CC) $(INCLUDE) -c $(SRC)/util.c
kmp.o: $(SRC)/kmp.c
	$(CC) $(INCLUDE) -c $(SRC)/kmp.c
form.o: $(SRC)/form.c
	$(CC) $(INCLUDE) -c $(SRC)/form.c
parcel.o: $(SRC)/parcel.c
	$(CC) $(INCLUDE) -c $(SRC)/parcel.c
clean:
	rm -rf $(OBJS) $(CGI_BIN)/* 
